/**
 * vfcode_md.js v2.0
 * https://gitee.com/thehot/auto/
 * 
 * Copyright 2019.06.24 From TheHot  -- QQ884627189
 * 
 */

//请勿用作商业用途，如有侵犯他人利益，请自行承担责任！！！
//请勿用作商业用途，如有侵犯他人利益，请自行承担责任！！！
//请勿用作商业用途，如有侵犯他人利益，请自行承担责任！！！

/** 以下为平台配置项，格式 {共享:{},火云:{},,,,,,,},其中属性为固定格式和数量，只需要复制更改属性值即可添加新平台 */
/** 以下为平台配置项，格式 {共享:{},火云:{},,,,,,,},其中属性为固定格式和数量，只需要复制更改属性值即可添加新平台 */
var modules = {}
var api_conf = {
    共享: {
        url: "http://api.ygcake.com/do.php?action=",  //平台API地址（固定属性名）
        common_string: {
            method_string: "get",  //访问API地址使用的方式(只有两个参数可选get/post)
            res_string: "string",  //返回值类型(只有两个参数可选 string/json)
            sid_string: "sid",  //项目ID属性名
            token_string: "token",  //token值属性名
            phone_string: "phone",  //提交手机号属性名
        },
        getSummary_string: {
            fist_string: "getSummary",  //获取账户信息地址接口后缀
            json_format: function (res) {  //处理POST请求返回的数据函数（根据返回值格式自行编写函数内容，返回值只能是 true 或者 flase，只为了验证是否登陆成功）
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",  //登陆接口后缀
            name_string: "name",  //用户名属性名
            pwd_string: "password",  //密码属性名
            json_format: function (res) {  //处理POST请求返回的数据函数（根据返回值格式自行编写函数内容，返回值只能是字符串）
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone",  //获取手机号属性名
            vno_string: "vno",  //虚拟号属性名
            phoneType_string: "phoneType",  //手机号类型属性名
            json_format: function (res) {  //处理POST请求返回的数据函数（根据返回值格式自行编写函数内容，正常返回值为手机号，可自行编写错误信息提示）
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){  //可自行添加扩展字符串，例如省市地区，格式参照获取验证码中的开发者扩展选项,注意的是必须且只能返回一个字符串或者是空字符
                return ""
            }  
        }, //必须有返回值，返回值只允许
        getCode_string: {
            fist_string: "getMessage",  //获取验证码属性名
            json_format: function (res) {  //处理POST请求返回的数据函数（根据返回值格式自行编写函数内容，只能返回对象，对象内容中tag值只能是0或1,0为未获取到验证码，1为获取成功，msg为请求返回的提示信息，可自行编写）
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv",  //释放手机号属性名
        },
        adbPhone_string: {
            fist_string: "addBlacklist"  //拉黑手机号属性名
        }
    },

    火云: {
        url: "http://huoyun888.cn/api/do.php?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "sid",
            token_string: "token",
            phone_string: "phone",
        },
        getSummary_string: {
            fist_string: "getSummary",
            json_format: function (res) {
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return ""
            }
        },
        getCode_string: {
            fist_string: "getMessage",
            json_format: function (res) {
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv",
        },
        adbPhone_string: {
            fist_string: "addBlacklist"
        }
    },

    多米: {
        url: "http://api.duomi01.com/api?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "sid",
            token_string: "token",
            phone_string: "phone",
        },
        getSummary_string: {
            fist_string: "getSummary",
            json_format: function (res) {
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return ""
            }
        },
        getCode_string: {
            fist_string: "getMessage",
            json_format: function (res) {
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv",
        },
        adbPhone_string: {
            fist_string: "addBlacklist"
        }
    },

    吸码皇: {
        url: "http://www.ximahuang.com/alz/api?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "sid",
            token_string: "token",
            phone_string: "phone",
        },
        getSummary_string: {
            fist_string: "getSummary",
            json_format: function (res) {
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return ""
            }
        },
        getCode_string: {
            fist_string: "getMessage",
            json_format: function (res) {
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv",
        },
        adbPhone_string: {
            fist_string: "addBlacklist"
        }
    },

    樱桃云: {
        url: "http://www.cherryun.com:8000/doApi/",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "sid",
            token_string: "token",
            phone_string: "phone",
        },
        getSummary_string: {
            fist_string: "getSummary?",
            json_format: function (res) {
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn?",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone?",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return ""
            }
        },
        getCode_string: {
            fist_string: "getMessage?",
            json_format: function (res) {
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv?",
        },
        adbPhone_string: {
            fist_string: "addBlacklist?"
        }
    },

    蚂蚁: {
        url: "http://www.66yzm.com/api/admin/",
        common_string: {
            method_string: "post",
            res_string: "json",
            sid_string: "itemid",
            token_string: "linpai",
            phone_string: "mobile",
        },
        getSummary_string: {
            fist_string: "usercenter?",
            json_format: function (res) {
                if (typeof res != "object") {
                    toastLog("登陆失败代码:" + res);
                    return false
                } else if (typeof res == "object") {
                    log(res)
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "dengl?",
            name_string: "zhanghao",
            pwd_string: "mima",
            json_format: function (res) {
                if (typeof res != "object") {
                    toastLog("登陆失败代码:" + res[1])
                    exit()
                }
                return res.token;
            }
        },
        getPhone_string: {
            fist_string: "getmobile?",
            vno_string: "xunihaoduan",
            phoneType_string: "operator",
            json_format: function (res) {
                if (res.length != 11) {
                    toastLog("手机号获取失败：" + res)
                    return -1
                } else if (res.length == 11) {
                    toastLog("手机号获取成功：" + res)
                    return res
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return ""
            }
        },
        getCode_string: {
            fist_string: "shortmessage?",
            json_format: function (res) {
                if (typeof res == "number") {
                    var tag = 0
                    var msg = "未获取到验证码！"
                } else if (typeof res == "object") {
                    var tag = 1
                    var msg = res['duanx']
                }
                return { tag: tag, msg: msg }   //0为未获取到验证码，1为成功
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "release?",
        },
        adbPhone_string: {
            fist_string: "blacklist?"
        }
    },

    短租: {
        url: "http://api.jmyzm.com/http.do?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "pid",
            token_string: "token",
            phone_string: "mobile",
        },
        getSummary_string: {
            fist_string: "getUserInfos",
            json_format: function (res) {
                if (res.indexOf(this.account) == -1) {
                    toastLog("本地Token验证失败！")
                    return -1
                }else{
                    return true
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",
            name_string: "uid",
            pwd_string: "pwd",
            json_format: function (res) {
                if (res.indexOf(modules.account) == -1) {
                    toastLog("短租账号登陆失败！")
                    exit()
                }
                token = res.split("|")
                return token[1]
            }
        },
        getPhone_string: {
            fist_string: "getMobilenum",
            vno_string: "vno",
            phoneType_string: "operator",
            json_format: function (res) {
                if(res.indexOf(modules.token) == -1){
                    toastLog("获取手机号失败！")
                    return -1
                }else{
                    let phone = res.split("|")
                    return phone[0]
                }
            },
            ext_string: function(){
                return "&size=1&uid=" + modules.account
            }
        },
        getCode_string: {
            fist_string: "getVcodeAndReleaseMobile",
            json_format: function (res) {
                if(res.indexOf("|") == -1){
                    tag = 0
                    msg = "未获取到短信！"
                }else{
                    let code = res.split("|")
                    tag = 1
                    msg = code[1]
                }
                return { tag: tag, msg: msg }   //0为未获取到验证码，1为成功
            },
            ext_string: function(){
                return "&author_uid=thehot"
            }
        },
        recPhone_string: {
            fist_string: "release?",
        },
        adbPhone_string: {
            fist_string: "addIgnoreList"
        }
    },

    易码: {
        url: "http://api.fxhyd.cn/UserInterface.aspx?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "itemid",
            token_string: "token",
            phone_string: "mobile",
        },
        getSummary_string: {
            fist_string: "getaccountinfo",
            json_format: function (res) {
                if (res.indexOf("success") == -1) {
                    toastLog("本地Token验证失败！")
                    return -1
                }else{
                    return true
                }
            }
        },
        getToken_string: {
            fist_string: "login",
            name_string: "username",
            pwd_string: "password",
            json_format: function (res) {
                if (res.indexOf("success") == -1) {
                    toastLog("短租账号登陆失败！")
                    exit()
                }
                token = res.split("|")
                return token[1]
            }
        },
        getPhone_string: {
            fist_string: "getmobile",
            vno_string: "excludeno",
            phoneType_string: "isp",
            json_format: function (res) {
                if(res.indexOf("success") == -1){
                    toastLog("获取手机号失败！")
                    return -1
                }else{
                    let phone = res.split("|")
                    return phone[1]
                }
            },
            ext_string: function(){
                return ""
            }
        },
        getCode_string: {
            fist_string: "getsms",
            json_format: function (res) {
                if(res.indexOf("success") == -1){
                    tag = 0
                    msg = "未获取到短信！"
                }else{
                    let code = res.split("|")
                    tag = 1
                    msg = code[1]
                }
                return { tag: tag, msg: msg }   //0为未获取到验证码，1为成功
            },
            ext_string: function(){
                return "&author_uid=thehot"
            }
        },
        recPhone_string: {
            fist_string: "release",
        },
        adbPhone_string: {
            fist_string: "addignore"
        }
    },

    芒果云: {
        url: "http://www.mangopt.com:9000/doApi/",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "itemid",
            token_string: "token",
            phone_string: "mobile",
        },
        getSummary_string: {
            fist_string: "getaccountinfo",
            json_format: function (res) {
                if (res.indexOf("success") == -1) {
                    toastLog("本地Token验证失败！")
                    return -1
                }else{
                    return true
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn?",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] != 1) {
                    toastLog("短租账号登陆失败！")
                    exit()
                }
                return token[1]
            }
        },
        getPhone_string: {
            fist_string: "getPhone?",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if(res[0] != 1){
                    toastLog("获取手机号失败！")
                    return -1
                }else{
                    let phone = res[1]
                    return phone
                }
            },
            ext_string: function(){
                return ""
            }
        },
        getCode_string: {
            fist_string: "getMessage?",
            json_format: function (res) {
                var res = res.split("|")
                if(res[0] != 1){
                    tag = 0
                    msg = "未获取到短信！"
                }else{
                    tag = 1
                    msg = res[1]
                }
                return { tag: tag, msg: msg }   //0为未获取到验证码，1为成功
            },
            ext_string: function(){
                return ""
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv?",
        },
        adbPhone_string: {
            fist_string: "addBlacklist?"
        }
    },

    飞蚁: {
        url: "http://api.skrsms.com/api/do.php?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "sid",
            token_string: "token",
            phone_string: "phone",
        },
        getSummary_string: {
            fist_string: "getSummary",
            json_format: function (res) {
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] != 1) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return "&count=1&author=thehot"
            }
        },
        getCode_string: {
            fist_string: "getMessage",
            json_format: function (res) {
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv",
        },
        adbPhone_string: {
            fist_string: "addBlacklist"
        }
    },

    信盒: {
        url: "http://api.xinheyz.com/api/do.php?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "sid",
            token_string: "token",
            phone_string: "phone",
        },
        getSummary_string: {
            fist_string: "getSummary",
            json_format: function (res) {
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] != 1) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return "&count=1&author=thehot"
            }
        },
        getCode_string: {
            fist_string: "getMessage",
            json_format: function (res) {
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv",
        },
        adbPhone_string: {
            fist_string: "addBlacklist"
        }
    },

    快米: {
        url: "http://api.kmiyz.com/api/do.php?action=",
        common_string: {
            method_string: "get",
            res_string: "string",
            sid_string: "sid",
            token_string: "token",
            phone_string: "phone",
        },
        getSummary_string: {
            fist_string: "getSummary",
            json_format: function (res) {
                var temp = res.split("|");
                if (temp[0] == 0) {
                    toastLog("登陆失败：" + res);
                    return false
                } else if (temp[0] == 1) {
                    return true
                } else {
                    return false
                }
            }
        },
        getToken_string: {
            fist_string: "loginIn",
            name_string: "name",
            pwd_string: "password",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] != 1) {
                    toastLog("登陆失败：" + res[1])
                    exit()
                }
                return res[1];
            }
        },
        getPhone_string: {
            fist_string: "getPhone",
            vno_string: "vno",
            phoneType_string: "phoneType",
            json_format: function (res) {
                var res = res.split("|")
                if (res[0] == 0) {
                    toastLog("手机号获取失败：" + res[1])
                    return -1
                } else if (res[0] == 1) {
                    toastLog("手机号获取成功：" + res[1])
                    return res[1]
                } else {
                    toastLog("获取手机号失败：未知错误！")
                    exit()
                }
            },
            ext_string: function(){
                return "&count=1&author=thehot"
            }
        },
        getCode_string: {
            fist_string: "getMessage",
            json_format: function (res) {
                var res = res.split("|")
                var tag = res[0]
                var msg = res[1]
                return { tag: tag, msg: msg }
            },
            ext_string: function(){
                return "&author=thehot"
            }
        },
        recPhone_string: {
            fist_string: "cancelRecv",
        },
        adbPhone_string: {
            fist_string: "addBlacklist"
        }
    },
}

/** 以下为核心代码，没有技术参考请勿改动，只需要添加相应属相到上面conf对象中即可 */
/** 以下为核心代码，没有技术参考请勿改动，只需要添加相应属相到上面conf对象中即可 */
/** 以下为核心代码，没有技术参考请勿改动，只需要添加相应属相到上面conf对象中即可 */

modules.init = function (platform, account, password, sid, ext) {
    this.platform = platform
    this.account = account
    this.password = password
    this.sid = sid
    this.ext = ext  //主要设置两个参数，虚拟号设置和手机号类型（vno，phoneType）
    this.debug = false
    if (platform == null && account == null && password == null) {
        toastLog("初始化失败，请填写必要参数！")
        exit()
    }
    
/*     if (typeof this.ext == "object") {
        if (this.ext.vno) {
            this.vno = this.ext.vno
        }
        if (this.ext.phoneType) {
            this.phoneType = this.ext.phoneType
        }
    } else {
        this.vno = ""
        this.phoneType = ""
    } //将扩展参数添加到对象的变量池中 */

    if(this.ext){
        if(this.ext.vno != "undefined"){
            this.vno = this.ext.vno
        }
        if(this.ext.phoneType != "undefined"){
            this.phoneType = this.ext.phoneType
        }
    }else{
        this.vno = ""
        this.phoneType = ""
    }

    //此处添加判断语句，判断是否存在此平台
    if(api_conf[platform] == "undefined"){
        toastLog("此平台暂未接入，请联系开发者！")
        exit()
    }else{
        this.conf = api_conf[platform] //初始化平台设置字段
    }
    /** 验证本地Token值的有效性并登陆返回账户信息 */
    var storage = storages.create(platform);
    if (storage.contains("token") == true && storage.contains("token").length > 10) {
        this.token = storage.get("token")
        if (modules.getSummary(this.token) == 0) {
            toastLog("本地Token验证成功！")
        } else {
            this.token = modules.getToken()
            storage.put("token", this.token)
        }
    } else {
        this.token = modules.getToken()
        storage.put("token", this.token)
    }
}

/** 以下为初始化所需函数实例 */
modules.getToken = function () {
    var token = modules.hddp(this.conf.url + this.conf.getToken_string.fist_string + "&" + this.conf.getToken_string.name_string + "=" + this.account + "&" + this.conf.getToken_string.pwd_string + "=" + this.password, "getToken")
    return token
}

modules.getSummary = function (token) {
    var r = modules.hddp(this.conf.url + this.conf.getSummary_string.fist_string + "&" + this.conf.common_string.token_string + "=" + token, "getSummary")
    if (r == true) {
        return 0
    } else {
        return -1
    }
}
/** 以上为初始化所需函数 */

/** 以下为获取手机号、获取验证码、释放验证码、加黑手机号函数实例 */
modules.getPhone = function (phone) {
    var ext_string = this.conf.getPhone_string.ext_string()
    if (phone != null) {
        var r = modules.hddp(this.conf.url + this.conf.getPhone_string.fist_string + "&" + this.conf.common_string.sid_string + "=" + this.sid + "&" + this.conf.common_string.token_string + "=" + this.token + "&" + this.conf.common_string.phone_string + "=" + phone, "getPhone")
    } else {
        var r = modules.hddp(this.conf.url + this.conf.getPhone_string.fist_string + "&" + this.conf.common_string.sid_string + "=" + this.sid + "&" + this.conf.common_string.token_string + "=" + this.token + "&" + this.conf.getPhone_string.vno_string + "=" + this.vno + "&" + this.conf.getPhone_string.phoneType_string + "=" + this.phoneType + ext_string, "getPhone")
    }
    return r
}

modules.getCode = function (phone, timeout, regx) {
    var ext_string = this.conf.getCode_string.ext_string()
    var phone = phone
    let tag = 0, k = 0
    if (timeout == null) {
        var timeout = 60;
    }
    if (regx == null) {
        var regx = /\d+/g;
    }
    while (tag == 0 && k < Math.ceil(timeout / 3)) {
        toastLog("未获取到短信,等待3秒重试！");
        sleep(3000);
        let res = modules.hddp(this.conf.url + this.conf.getCode_string.fist_string + "&" + this.conf.common_string.sid_string + "=" + this.sid + "&" + this.conf.common_string.token_string + "=" + this.token + "&" + this.conf.common_string.phone_string + "=" + phone + ext_string, "getCode")
        var tag = res.tag
        var code = res.msg
        k = k + 1;
    }
    if (tag == 0) {
        toastLog("获取验证码超时或失败！");
        return -1;
    }
    code = code.match(regx);
    return code[0];
}

modules.recPhone = function (phone) {
    var phone = phone
    let res = modules.hddp(this.conf.url + this.conf.recPhone_string.fist_string + "&" + this.conf.common_string.sid_string + "=" + this.sid + "&" + this.conf.common_string.token_string + "=" + this.token + "&" + this.conf.common_string.phone_string + "=" + phone, "recPhone")
    return res
}

modules.adbPhone = function (phone) {
    var phone = phone
    let res = modules.hddp(this.conf.url + this.conf.adbPhone_string.fist_string + "&" + this.conf.common_string.sid_string + "=" + this.sid + "&" + this.conf.common_string.token_string + "=" + this.token + "&" + this.conf.common_string.phone_string + "=" + phone, "adbPhone")
    return res
}

modules.hddp = function (url, obj_name) {
    let method = this.conf.common_string.method_string
    let res_form = this.conf.common_string.res_string
    var url = url
    var obj_name = obj_name + "_string"
    if (method == "get") {
        var r = http.get(url)
    } else if (method == "post") {
        var r = http.post(url, {})
    } else {
        toastLog("平台初始化失败，请联系作者！")
        exit()
    }
    if(this.debug == true){  //debug
        log(r.body)
    }
    if (obj_name == "recPhone_string" || obj_name == "adbPhone_string") {
        if (res_form == "string") {
            var res = r.body.string()
        } else if (res_form == "json") {
            try {
                var res = r.body.json()
            } catch (e) {
                var res = r.body.string()
            }
        } else {
            toastLog("平台初始化失败，请联系作者！")
            exit()
        }
    } else {
        if (res_form == "string") {
            var res = this.conf[obj_name].json_format(r.body.string())
        } else if (res_form == "json") {
            var res = this.conf[obj_name].json_format(r.body.json())
        } else {
            toastLog("平台初始化失败，请联系作者！")
            exit()
        }
    }
    if (res) {
        return res
    } else {
        toastLog("未返回任何数据，请检查平台信息！")
        exit()
    }
    return res
}

module.exports = modules;